package com.zzuli.demo01.action;

import com.opensymphony.xwork2.Action;
import com.zzuli.demo01.dao.UserDaoImpl;
import com.zzuli.demo01.pojo.User;
import org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Zyh
 * @date 2020/9/23/0023 21:22
 */
public class LoginAction implements Action {
    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String execute() throws Exception {
        UserDaoImpl userDao = new UserDaoImpl();

        User user = userDao.getUser(username, password);

        if (user != null){
            return "success";
        }else {
            return "error";
        }

    }
}
